<%@ Control Language="C#" Inherits="System.Web.Mvc.ViewUserControl<RulingInput>" %>
<% using (Html.BeginForm())
   {%>
<div class='ia'>
    <%= Html.HiddenFor(o => o.CaseId)%>
    <%= Html.EditorFor(o => o.RulingTypeId)%>
    <%= Html.EditorFor(o => o.TemplateId)%>
</div>
<div class='ia'>
    <%= Html.EditorFor(o => o.HearingId)%>
    <%if (Model.Status != "F")
      {%>
    <%= Html.EditorFor(o => o.Status)%>
    <%}%>
</div>
<%= Html.EditorFor(o => o.DocBytes)%>
<%
   }
%>
<div id='stuff'>
    <ul class="editorlist">
        <li>hi</li>
        <li>how are you</li>
        <li>good</li>
    </ul>
</div>
<script type='text/javascript'>
    function aaa() {
        $('<a href="#" id="stuffadd" class="abtn">adauga text predefinit</a>')
        .click(function () { $('#stuff').dialog('open'); }).appendTo('.cke_button:last'); //.cke_toolbox
        $ae.mybutton('#stuffadd');
    }

    function makeli() {
        $('.editorlist li').click(function () {
            CKEDITOR.instances["DocBytes"].insertText($(this).html());
        }).hover(
        function () { $(this).addClass('ui-state-active'); },
        function () { $(this).removeClass('ui-state-active'); }
        );
    }

    $(function () {
        $('#stuff').dialog({
            autoOpen: false,
            zIndex: 9999,
            resizable: false,
            height: 200
        });

        setTimeout('aaa()', 1000);

        //radio final on click
        $('#Statuslist input[value="F"]').die().live('click', function (e) {
            if (!confirm("Sunteti sigur?")) {
                $(this).removeAttr('checked');
                $('#Statuslist input[value="D"]').attr('checked', 'checked');
            }
        });

        $('#TemplateId').change(function () {
            $.post('<%=Url.Action("GetTemplateContent","Aja") %>', { id: $('#TemplateId').val() }, function (d) {
                CKEDITOR.instances["DocBytes"].setData(d);
            });
        });

        //fill the cleditor content
        $.post('<%=Url.Action("GetCleditorItems","Aja") %>', { caseId: $('#CaseId').val() }, function (d) {
            $('#stuff > ul').html('');
            $.each(d, function (i, k) { $('#stuff > ul').prepend('<li>' + k + '</li>'); });
            makeli();
        });

        $('#HearingId').change(function () {
            $.post('<%=Url.Action("GetCleditorItems","Aja") %>', { caseId: $('#CaseId').val(), hearingId: $('#HearingId').val() }, function (d) {
                $('#stuff > ul').html('');
                $.each(d, function (i, k) { $('#stuff > ul').prepend('<li>' + k + '</li>'); });
                makeli();
            });
        });
    });
</script>